package com.liaogui.web.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * 点赞
 * @author liaogui
 * @date 2025/3/2 18:48
 */
@RestController
@RequestMapping("/like")
@RequiredArgsConstructor
public class GiveLikeController {
    private final RedisTemplate<String, Object> redisTemplate;
    @PostMapping
    public String giveLike() {
        String likeKey = "act:like:ACT202502281645";
        List<String> userList = Arrays.asList("userId01", "userId02", "userId03", "userId04", "userId04");
        // 模拟用户点赞
        for (String userId : userList) {
            redisTemplate.opsForSet().add(likeKey, userId);
        }
        return "点赞成功";
    }
}
